package com.yang.controller.admin;

import com.yang.bean.MarketAD;
import com.yang.bean.common.BasePageInfo;
import com.yang.bean.common.BaseRespVo;
import com.yang.bean.common.CommonData;
import com.yang.service.admin.AdminAdService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("admin/ad")
public class AdminAdController {
    @Autowired
    AdminAdService adminAdService;

    @RequestMapping("list")
    public BaseRespVo<CommonData<MarketAD>> queryAllAd(String name, String content, BasePageInfo info) {
        BaseRespVo<CommonData<MarketAD>> baseRespVo = adminAdService.queryAllAd(name, content, info);
        return baseRespVo;
    }

    @RequestMapping("create")
    public BaseRespVo<MarketAD> addAd(@RequestBody MarketAD marketAD) {
        BaseRespVo<MarketAD> baseRespVo = adminAdService.addAd(marketAD);
        return baseRespVo;
    }

    @RequestMapping("update")
    public BaseRespVo<MarketAD> updateAd(@RequestBody MarketAD marketAD) {
        BaseRespVo<MarketAD> baseRespVo = adminAdService.updateAd(marketAD);
        return baseRespVo;
    }

    @RequestMapping("delete")
    public BaseRespVo deleteAd(@RequestBody MarketAD marketAD) {
        adminAdService.deleteAd(marketAD);
        return BaseRespVo.ok(null);
    }

}
